def maxCommonSubString(s1:str,s2:str):
    for length in range(len(s2), -1, -1):
        left = 0
        right = length - 1
        while right < len(s2):
            s3 = s2[left:right + 1]
            if s1.count(s3) >= 1 :
                return s3
            left += 1
            right += 1
    return ""
s1 = input()
s2 = input()
print(maxCommonSubString(s1,s2))

